import Vue from 'vue'
import App from './App.vue'
//引入ElementUi组件
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
//引入路由器
import VueRouter from "vue-router";
//引入多语言切换i18n
import vueI18nEsm from "vue-i18n";
import en from './components/i18n/en.json'
import zh from './components/i18n/zh.json'
import ru from './components/i18n/ru.json'
//关闭VUE生产提示
Vue.config.productionTip = false

import router from "@/router";
import request from "@/components/utils/request";
import requestFile from "@/components/utils/requestFile";
import translate from "@/components/utils/translate";

//插入ElementUI插件
Vue.use(ElementUI);
//使用路由器插件
Vue.use(VueRouter);
//使用i18n
Vue.use(vueI18nEsm)
//创建i18n实例
const i18n = new vueI18nEsm({
  locale: localStorage.getItem('app_lang') || 'zh',//默认语言
  fallbackLocale:'en',//回退语言
  messages:{
    zh:{...zh},
    en:{...en},
    ru:{...ru},
  },
  //启用语言环境检测
  detect:{
    localStorage:'app_lang',//从localStorage读取
    navigator:true,//浏览器语言
    watch:true//实时监控变化
  }
})

//把封装的网络请求形成全局的变量
Vue.prototype.$request=request;
Vue.prototype.$requestFile=requestFile

// 注册全局翻译插件
Vue.prototype.$translate=translate

new Vue({
  i18n,
  render: h => h(App),
  beforeCreate() {
    Vue.prototype.$bus=this //安装全局事件总线
  },
  router:router
}).$mount('#app')
